package cm.tl.pms.util.async;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.concurrent.Executor;

/**
 * @author: lwp
 * @date: 2024/11/14 15:02
 * @description
 * @version: 1.0
 */
@Configuration
public class AsyncConfig {

    /**
     * 日志线程池
     *
     * @return
     */
    @Bean(name = "LogThreadPool")
    public Executor taskExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(10); // 核心线程数
        executor.setMaxPoolSize(20);  // 最大线程数
        executor.setQueueCapacity(100); // 队列容量
        executor.setThreadNamePrefix("LogThreadPool-"); // 线程名称前缀
        executor.initialize();
        return executor;
    }

}
